﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using BSCMFF.Core.DataAccessLayer;
using BSCMFF.Core.Exceptions.Database;

namespace BSCMFF.Web.Pages.Evaluation_Setup
{
    public partial class AssignEvaluation : BSCMFF.Core.MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            BSCEntities context = new BSCEntities();

            //List<User> users = (from eu in context.Evaluation_User.Include("User.SBU")
            //                    where eu.Evaluation_FK == 28
            //                    select eu.User).ToList();

            //RadGridAssignedEmployees.DataSource = users;
            //RadGridAssignedEmployees.DataBind();
        }

        protected void RadComboBoxEvaluations_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            int evalID = Int32.Parse(e.Value);

            BSCEntities context = new BSCEntities();

            //List<User> users = (from eu in context.Evaluation_User.Include("User.SBU")
            //                    where eu.Evaluation_FK == evalID
            //                    select eu.User).ToList();

            //RadGridAssignedEmployees.DataSource = users;
            //RadGridAssignedEmployees.DataBind();
        }

        protected void RadButtonAssignUsers_Click(object sender, EventArgs e)
        {
            BSCEntities context = new BSCEntities();

            foreach (RadListBoxItem rlbi in EGS.RadListBoxSelectedEmployees.Items)
            {
                //Evaluation_User eu = new Evaluation_User();
                //eu.User_FK = Int32.Parse(rlbi.Value);
                //eu.Evaluation_FK = Int32.Parse(RadComboBoxEvaluations.SelectedValue);

                //context.AddToEvaluation_User(eu);
            }

            try
            {
                context.SaveChanges();
            }
            catch
            {
                throw new InconsistentDatabaseException("Couldn't assign Employees");
            }
        }
    }
}